package connect4client.commands;

import messages.*;

/**
 * The PluginOperationFailed command.
 * 
 * This command will handle PluginOperationFailed messages.
 */
public class PluginOperationFailedCommand extends Command {

	public PluginOperationFailedCommand(PluginOperationFailedMessage message){
		super(message);
	}
	
	@Override
	public void execute() {		
		Message originalMessage = ((PluginOperationFailedMessage) message).getOriginalMessage();
		
		if (originalMessage instanceof StartPluginMessage) {
			StartPluginMessage startMessage = (StartPluginMessage) originalMessage;
			guiMediator.pluginStartupFailed(startMessage.getSenderLogin(), startMessage.getPluginName());
		} else if (originalMessage instanceof StopPluginMessage) {
			StopPluginMessage stopMessage = (StopPluginMessage) originalMessage;
			guiMediator.pluginShutdownFailed(stopMessage.getSenderLogin(), stopMessage.getPluginName());
		}
	}
}
